<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<!-- $Id: tips.html 1463 2010-11-08 21:40:13Z ftruscot $ -->
	<title>Nucleus - Tips and suggestions</title>
	<link rel="stylesheet" type="text/css" href="styles/manual.css" />
</head>
<body>

<div class="heading">
<a name="top" />
Tips &amp; Suggestions
</div>

<h1>Introduction</h1>

<p>
<a href="index.html">Back to the manual</a>
</p>

<p>
This file contains tips and suggestions that might prove useful.
</p>

<h1><a name="toc"></a>Table Of Contents</h1>

<ul>
	<li>
		<a href="#searchengines">How to get your archives into search engines?</a>
		<ul>
			<li><a href="#searchengines-fancyurls">Fancy URLs</a></li>
			<li><a href="#searchengines-rewrite">mod_rewrite</a></li>
			<li><a href="#fancyurls-2">Fancy URLs 2</a></li>
		</ul>
	</li>
	<li><a href="#filepermissions">How to set file/dir permissions?</a></li>
	<li><a href="#backups">How to restore backups</a></li>
	<li><a href="#newblog">How to create a new weblogs</a></li>
	<li><a href="#xhtml">XHTML support</a></li>
	<li><a href="#specialskinpart">How to create a Special skin part</a></li>
<!--
	<li><a href="#"></a></li>
	<li><a href="#"></a></li>
	<li><a href="#"></a></li>
-->
</ul>










<h1>Getting your archives into search engines like Google <a name="searchengines" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1>

<div class="note">
<b>Note:</b> The solutions described here might not work on your system.
</div>

<p>
Nucleus creates archives dynamically on users requests. The URL is then of the form <code>index.php?archive=2001-09&amp;blogid=1</code>. Unfortunately, Google and other search engines don't like to index pages with a question mark in it, or with too much arguments. This is because their spiders might get trapped going too deep.
</p>

<p>Two solutions are listed below. They're not guaranteed to work, however (wether they work or not depends on the webserver configuration)</p>

<ol>
	<li><a href="#searchengines-fancyurls">Fancy URLs</a></li>
	<li><a href="#searchengines-rewrite">mod_rewrite</a></li>
	<li><a href="#fancyurls-2">Fancy URLs 2</a></li>
</ol>


<h2><a name="searchengines-fancyurls"></a>Fancy URLs</h2>

<p>Nucleus v2.0 has a new option in the global settings 'URL mode'. Setting it to 'Fancy URL' mode, and performing the steps below, will make your URLs look like <code>http://example.org/item/1234</code> instead of <code>http://example.org/index.php?itemid=1234</code>. Search engines like these URLs better.</p>

<p>Installation steps:</p>

<ol>
	<li>Copy all files from the <code>/extra/fancyurls</code> directory (except for <code>index.html</code>) to your main nucleus dir (that's where your <code>index.php</code> and <code>action.php</code> file are)</li>
	<li>If you have an already existing <code>.htaccess</code> file (most ftp-programs don't show hidden files by default, so don't start uploading it without checking your server). If you do, download that old one first, and copy the contents of the new <code>.htaccess</code> file (from the fancyurls folder) in your old one, and upload that...</li>
	<li>Edit the <code>fancyurls.config.php</code> file so that <code>$CONF['Self']</code> points to your main directory. <br /><strong>NOTE: this time, and only this time, the URL should <em>NOT</em> end in a slash</strong></li>
	<li>Also edit the <code>$CONF['Self']</code> variable in your <code>index.php</code>, if you don't want to end up with <code>index.php/item/1234</code> urls when people come via that way</li>
	<li>Enable 'Fancy URLs' in the Nucleus admin area (nucleus management / edit settings)</li>
	<li>Off you go!</li>
</ol>

<p>When it doesn't work (e.g. you receive an Internal Server Error): bad luck... Remove the files again (don't forget the hidden file <code>.htaccess</code>) and reset the Fancy URLs setting in the admin area.</p>



<h2><a name="searchengines-rewrite"></a>mod_rewrite</h2>

<p>
This second possible solution will only work on servers running Apache, and when you have the right to do so. What we will do is 'disguise' the archives as regular HTML pages
</p>

<p>
Create a file called <code>.htaccess</code> (leading dot!) with the following contents:
</p>

<pre>
RewriteEngine On
RewriteRule ^archive-([0-9]+)-([0-9]+)-([0-9]+).html+ index.php?archive=$2-$3&amp;blogid=$1
RewriteRule ^item-([0-9]+).html+ index.php?itemid=$1
RewriteRule ^archivelist-([a-z]+).html+ index.php?archivelist=$1
</pre>

<p>
Now upload this file to the directory that contains <i>index.php</i> and <i>config.php</i>. Open your browser and try to open <code>archive-1-2001-09.html</code>. If it works, continue to read. If you get a 500 error (internal server error), it does not work on your server, so delete the .htaccess file.
</p>

<p>
Now all you have to do is to update the link to your blog archives into <code>archivelist-<i>shortblogname</i>.html</code> and make the following changes to your archivelist item template:
</p>

<pre>
&lt;a href="archive-&lt;%blogid%&gt;-&lt;%year%&gt;-&lt;%month%&gt;.html"&gt;...&lt;/a&gt;
</pre>

<p>
And now, wait until Google comes spidering again...
</p>


<h2><a name="fancyurls-2"></a>Fancy URLs 2</h2>

<p>Nucleus CMS version 3.3 offers an easier way to enable the basic Fancy URLs. There are only three steps necessary to install this solution:</p>

<ol><li>Copy or move the <code>.htaccess</code> file from <code>extra/fancyurl-2</code> to the root directory of your Nucleus CMS installation.</li>
<li>Edit the <code>index.php</code> file which you can find in your root directory. Change value of the <code>CONF['Self']</code> from the  default value (<code>'index.php'</code>) to the URL that points to your root directory, for example:<br />
<pre>CONF['Self'] = 'http://yourdomain.com/yourNucleusDirectory';</pre>
Don't use a slash at the end.<br /></li>
<li>Enable the 'Fancy URLs' in the Nucleus admin area, you can find this setting under <em>Management &gt; Configuration</em>.</li></ol>

<p>Everything done.</p>

<p>If you want to use rewritten URLs like <code>item/this-is-a-title</code> you can find plugin solutions for it in the Nucleus Plugin Wiki, for example <a href="http://wakka.xiffy.nl/fancierurl2">NP_FancierURL2</a>.</p>

<h1>How to set file/dir permissions <a name="filepermissions" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1>

<p>
To enable some features of Nucleus, changing file permissions is required. A small guide on how to do this using an FTP client is given below.
</p>

<p>
First of all, you'll need an FTP client that supports file permission changing. In this example, we'll use CuteFTP. You can <a href="http://www.cuteftp.com/products/cuteftp/">download a free trial version</a> if you don't have it.
</p>

<p>
To change the permissions of a file or directory, create an FTP connection to your website and search for that file or directory in the hierarchy. Select the file by clicking on it.
</p>

<p>
Open the menu <tt>Commands &gt; File Actions &gt; CHMOD...</tt> for a file, or <tt>Commands &gt; Directory &gt; CHMOD...</tt> for a directory.
</p>

<div class="screenshot">
	<img src="pics/chmod_menu.png" width="381" height="218" alt="menu" />
</div>

<p>
A window will pop up:
</p>

<div class="screenshot">
	<img src="pics/chmod_window.png" width="260" height="326" alt="The window that pops up" />
</div>

<p>
On the bottom, you can enter the code that's given in the documentation (e.g. 755 or 444). Click the <tt>OK</tt> button and the changes will be applied. You're finished now.
</p>

<h1>How to restore backups <a name="backups" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1>

<p>
Nucleus has a backup/restore option that super-admins can use to create a backup of the database. It's strongly encouraged to take a backup regularly (weekly or so). The backup-files that are returned are files containing standard SQL-queries, that reconstruct the state of the database as it was when the backup was created.
</p>

<p>
While backing up is easy, and restoring should also be easy, problems might pop up when your database is fucked up beyond repair. In that case, the repair function might become unaccessible. Below are some ways you can restore your database in that case:
</p>

<div class="note">
If you're backup was gzipped, unzip if first (it contains an sql file)
</div>


<h2>Possibility 1: Web-based</h2>

<p>
If you have a web-based interface through which you can manage your database (e.g. <a href="http://phpmyadmin.sourceforge.net/">PHPMyAdmin</a>), there's most likely an option where you can import a file into the database. Use this function to restore your database.
</p>

<h2>Possibility 2: Shell-access</h2>

<p>
If you have a shell account, restoring a backup can be done by running the <tt>mysql</tt> program with the following arguments:
</p>

<pre>
mysql -u <i>username</i> -p -h <i>hostname</i> <i>databasename</i> &lt; <i>backupfile.sql</i>
</pre>


<h1>How to create a new weblog <a name="newblog" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1>

<h2>1. Creating the weblog</h2>

<p>As a superadmin, you can create new weblogs from the 'Nucleus Management' screen. They will then show up on the admin area.</p>

<h2>2. Accessing your new weblog</h2>

<p>There are several ways in which you can make your new weblog accessible.</p>

<ol>
	<li>Using a <strong><code>blogid</code> attribute</strong> in the URL:
		<pre><code>http://yourhost.com/index.php?blogid=<i>2</i></code></pre>
		(You can find the blogid in the admin area, when hovering over the blog name in the blog list)
	</li>
	<li>
		By creating a <strong>copy of the <code>index.php</code> file</strong> (in this example, our file is named <tt>copy.php</tt>), and editing the contents of the file to look like this:
		<pre><code>$CONF['Self'] = '<i>copy.php</i>';
include('./config.php');
selectBlog('<i>shortblogname</i>');
selector();

?></code></pre>
		(You can find the short blog name in the admin area, when hovering over the blog name in the blog list)
	</li>
</ol>

<h2>Extra methods to use in copy.php</h2>

<p>The <tt>selectBlog</tt> is only one of the methods which you can use in copies of <tt>index.php</tt> files. Here's a list of the available calls:</p>

<table><tr>
	<th>Method</th>
	<th>Description</th>
</tr><tr>
	<td><code>selectBlog('shortblogname');</code></td>
	<td>Makes sure a certain blog gets selected</td>
</tr><tr>
	<td><code>selectSkin('skinname');</code></td>
	<td>Makes sure a certain skin gets selected</td>
</tr><tr>
	<td><code>selectCategory(1234);</code></td>
	<td>Makes sure a certain category gets selected. Takes a category id as argument. Also accepts a category name (keep in mind that this can cause problems if multiple categories have the same name)</td>
</tr><tr>
	<td><code>selectItem(1234);</code></td>
	<td>Makes sure a certain item gets selected</td>
</tr><tr>
	<td><code>selectLanguage('french');</code></td>
	<td>Makes sure a certain language gets used (note: might produce PHP warnings)</td>
</tr><tr>
	<td><code>selectSpecialSkinType('construction');</code></td>
	<td>Makes sure a certain special skin type gets used (note: if used by itself, it will only show that special skin type). Try this to show the special page only to non-members: <pre><code>if (!$member->isLoggedIn()) {
	selectSpecialSkinType('login');
}</code></pre> or this to show the special skin type only for the main page: <pre><code>if (empty($blogid) && empty($catid) && empty($itemid)&& empty($archive) && empty($archivelist) && empty($special)) {
	selectSpecialSkinType('welcome');
}</code></pre></td>
</tr></table>

<p>
Make sure that these methods are called <strong>after</strong> the <code>include('./config.php')</code> statement, and <strong>before</strong> the <code>selector();</code> statement!
</p>

<h2>Creating a blog in a subdirectory</h2>

<p>The process for creating a blog in a subdirectory (<tt>http://yourhost.com/sub/</tt> where the main weblog is in <tt>http://yourhost.com/</tt>) is similar, with the only change that you'll need to replace <code>include('./config.php');</code> by <code>include('../config.php');</code></p>















<h1>XHTML Support <a name="xhtml" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1>

<p>
If you see tags like <code>&lt;br /&gt;</code> in the source code of your webpage, it's because the output of Nucleus <small>(except the things defined by templates and skins, of course)</small> is compliant to the XHTML 1.0 standard from the W3C, which is the successor of HTML 4. This way, Nucleus is ready for the future of the web. As far as I know, this XHTML support does not cause any trouble with older browsers and is correctly interpreted.
</p>

<p>
What this means, is that you can perfectly create an XHTML-compliant site by using correct skins and templates. The default Nucleus skin is XHTML-compliant, but uses the "HTML 4 Loose" doctype. This way, users not knowing XHTML can not create documents with a false XHTML doctype.
</p>











<h1>How to create a Special skin part <a name="specialskinpart" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1>

<p>1. Enter the Nucleus admin area and go to Skins management page (<strong>Layout>Skins</strong>). Find your skin and click the Edit link in the right column.</p>

<p>2. Under the list of skin parts there is a sections called Special skin parts. In the field type the name of your special skin part and then click the Create button. (I'm using the name 'About' for my example). You then get a Edit skin part form, just like for any other skin part, that you can add content, skin variables or anything else. If you want to make it look like the rest of your site, you can copy the contents of the Main Index skinpart here and replace the <code>&lt;%body(...)%&gt;</code> skin variable with the contents of the static page.<br />
<br />
For example, using the default skin, the contents of the About skin part would look something like this:</p>
<pre><code>&lt;%parsedinclude(head.inc)%&gt;

&lt;!-- page header --&gt;
&lt;%parsedinclude(header.inc)%&gt;

&lt;!-- page content --&gt;
&lt;div id="container"&gt;
&lt;div class="content"&gt;
This site is run by a group of friends who all enjoy hiking. Together we have
hiked a total of over 4000 miles though out the US, Canada and Europe. Here we
share our experiences and our experience. Though we are serious hikers, we
believe hiking should first be fun for everybody.
&lt;br /&gt;&lt;br /&gt;
To join our community, please register here: (...link to registration page...)
&lt;br /&gt;&lt;br /&gt;
... insert links to images of hiking fun...
&lt;/div&gt;
&lt;/div&gt;

&lt;!-- page menu --&gt;
&lt;h2 class="hidden"&gt;Sidebar&lt;/h2&gt;
&lt;div id="sidebarcontainer"&gt;
&lt;%parsedinclude(sidebar.inc)%&gt;
&lt;/div&gt;

&lt;!-- page footer --&gt;
&lt;%parsedinclude(footer.inc)%&gt;</code></pre>

<p>3. Now to access this page, you would point your browser (or put a link in your skin somewhere) to </p>

<pre><code>www.yourdomain.tld/index.php?special=About</code></pre>


<p>4. You can edit this skin part just as you would any other skin part and most skin variables and plugins will probably work.</p>

<p><strong>Note:</strong> You may want to keep your static content in a file called <code>About.html</code> in the <code>skins/default/</code> directory (if using the default skin) and instead of typing the content of the page in the skin part, just put <code>&lt;%include(About.html)%&gt;</code>. There's almost no restriction on what these pages can contain.</p>

<p>(Tip from  <a href="http://revcetera.com/ftruscot">ftruscot</a>)</p>

</body>
</html>